<template>
<div>
  <h1>文章展示</h1>
  <table align="center" border="1" cellpadding="1">
    <tr>
      <td>标题</td>
      <td>操作</td>
    </tr>
    <tr v-for="i in list">
      <td>{{i.name}}</td>
      <td>
        <button @click="qx(i.id)">详情</button>
      </td>
    </tr>
  </table>
  <button @click="show(i)" v-for="i in num">{{i}}</button>

</div>
</template>

<script>
export default {
  name: "wenzhang",
  data(){
    return{
      list:[],
      num:'',
      userid:localStorage.getItem('userid')
    }
  },
  methods:{
    show(i){
      this.$axios.get('users/Wenzhang_API/?cpage='+i)
      .then(i=>{
        this.list = i.data.list
        this.num = i.data.num
      })
    },
    qx(i){
      if (this.userid){
        this.$router.push({path:'/wpl',query:{id:i}})
      }
      else {
        alert('请先登录')
        this.$router.push('/wlogin')
      }
    }
  },
  mounted() {
    this.show(1)
  }
}
</script>

<style scoped>

</style>
